package org.example;

import java.util.Arrays;
import java.util.Random;


public class Main {




    //初始化数组
    public static void orderArray(int[] array){
        for (int i = 0; i < array.length; i++) {
            array[i] = i;
           // array[i] = array.length-1;
        }
    }
    public static void notOrderArray(int[] array){
        Random random = new Random();
        for (int i = 0; i < array.length; i++) {
            array[i] = random.nextInt(10_0000);
        }
    }





    public static void testInsert(int[] array){
        array = Arrays.copyOf(array,array.length);
        long startTime = System.currentTimeMillis();
        Sort.insertSort(array);
        long endTime = System.currentTimeMillis();
        System.out.println("直接插入排序耗时:" + (endTime-startTime));
    }

    public static  void testshellSort(int[] array){
        array = Arrays.copyOf(array,array.length);
        long startTime = System.currentTimeMillis();
        Sort.shellSort(array);
        long endTime = System.currentTimeMillis();
        System.out.println("希尔排序耗时:" + (endTime-startTime));
    }




    /**
     * 测试简单算法能否执行，测试算法是否正确
     * @param
     */
    public static void testSimple() {
        int[] array = {12,5,2,9,10,7};
        System.out.println("排序前:" +  Arrays.toString(array));
        //Sort.insertSort(array);
        Sort.shellSort(array);
        System.out.println("排序后:"+Arrays.toString(array));
    }


    public  static  void testOther(){
        int[] array = new int[10_0000];
        orderArray(array);
        //notOrderArray(array);
        testInsert(array);
        testshellSort(array);
    }

    public static void main(String[] args) {
        testSimple();
        //testOther();
    }

}